package zzh.com.myapplication.test;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * Created by qwert on 2017/7/2.
 */

public class VPAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> fragmentList;

    public VPAdapter(FragmentManager fragmentManager, List<Fragment> list) {
        super(fragmentManager);
        this.fragmentList = list;
    }

    public VPAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0)
            return fragmentList.get(0);
        if (position == 1)
            return fragmentList.get(1);
        else
            return fragmentList.get(2);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

}
